﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace Common
{
    public class User
    {
        public string Name { get; set; }
        public string UserName { get; set; }
        public bool IsAdmin { get; set; }
        public Guid ID { get; set; }
        public Guid Password { get; set; }

        public User(Guid id, string name, string userName, Guid password, bool isAdmin)
        {
            this.ID = id;
            this.Name = name;
            this.UserName = userName;
            this.Password = password;
            this.IsAdmin = isAdmin;
        }

        public static Guid GetHashString(string s)
        {
            byte[] byteValue = Encoding.Unicode.GetBytes(s);
            MD5CryptoServiceProvider csp = new MD5CryptoServiceProvider();

            byte[] byteHash = csp.ComputeHash(byteValue);
            string result = string.Empty;
            foreach (byte b in byteHash)
                result += string.Format("{0:x2}", b);
            return new Guid(result);
        }
    }
}
